import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [{
  path: '/',
  component: () => import( /* webpackChunkName: "index" */ '../views/index.vue'),
  meta: {
    title: '首页'
  }
}, {
  path: '/local/:name',
  name: 'local',
  component: () => import( /* webpackChunkName: "local" */ '../views/local/index.vue'),
  meta: {
    title: '局部铺码'
  }
}]

const router = new VueRouter({ mode: 'history', routes })

// nprogress
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
// 路由守卫 - 路由跳转前
router.beforeEach((to, from, next) => {
  NProgress.start()
  document.title = to.meta.title
  setTimeout(next, 250);
})
router.afterEach(NProgress.done)

export default router